1 using UnityEngine;
2 using
System.Collections;
3
4 public
class CameraFollow : MonoBehaviour {
5
6     
public GameObject Target; // the main chracter that the camera follows
7     
public float cameraSmoothing = 5.0f;
8
9     Vector3 offset;
// the distance between the main character and the camera
10     
// Use this for initialization
11     
void Start () {
12         offset = transform.position - Target.transform.position;
13     
14     }
15     
16     
// Update is called once per frame
17     
void Update () {
18         Vector3 targetCamera = Target.transform.position + offset;
19
20         transform.position = Vector3.Lerp (transform.position, targetCamera, Time.deltaTime * cameraSmoothing);
21     
22     }
23 }


Gõ tìm kiếm nhanh...